package service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import dao.CustomerDao;
import pojo.Customer;
import service.CustomerManager;

@Component
public class CustomerManagerImpl implements CustomerManager{
	
	@Resource(name="customerDao")
	private CustomerDao dao;
	
	public CustomerManagerImpl() {
	}
	
	@Override
	public Customer addCustomer(Customer c) {
			if(dao.addCustomer(c)>0) {
				return c;
			}else
				return null;
	}

	@Override
	public Customer updateCustomer(Customer c) {
		if(dao.updateCustomer(c)>0){
			return c; 
		}else {
			return null;
		}
	}

	@Override
	public List<Customer> findAllCustomers() {
		List<Customer> list = dao.findAllCustomers();
		if(list==null) {
			list = new ArrayList<Customer>();
		}
		return list;
	}

	@Override
	public String deleteCustomer(String id) {
		dao.deleteCustomer(id);
		return "{}";
	}

}
